﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using LumenLiquid._2D;
using Microsoft.Xna.Framework.Content;

namespace LumenLiquid
{
	public class ScreenManager : IDrawable
	{
		#region Public Delegates
		public delegate void Draw(GameTime gametime, SpriteBatch spritebatch, GraphicsDevice device);
		public delegate void Update(GameTime gametime);
		#endregion

		bool paint_cursor;
		Texture2D cursor;

		
		List<Draw> draw_functions;
		List<Update> update_functions;

		#region List Functions
		/// <summary>
		/// Adds a new Draw Routine to the list
		/// </summary>
		/// <param name="function">The function to be added</param>
		public void AddDraw(Draw function)
		{
			draw_functions.Insert(0, function);
		}

		/// <summary>
		/// Adds a new Update Routine to the list
		/// </summary>
		/// <param name="function">The function to be added</param>
		public void AddUpdate(Update function)
		{
			update_functions.Insert(0, function);
		}

		/// <summary>
		/// Removes a Draw Routine from the list
		/// </summary>
		/// <param name="function">The function to remove</param>
		public void RemoveDraw(Draw function)
		{
			draw_functions.Remove(function);
		}

		/// <summary>
		/// Removes an Update Routine from the list
		/// </summary>
		/// <param name="function">The function to remove</param>
		public void RemoveUpdate(Update function)
		{
			update_functions.Remove(function);
		}

		/// <summary>
		/// Removes all Draw Functions from the list
		/// </summary>
		public void ClearDraw()
		{ draw_functions.Clear(); }

		/// <summary>
		/// Removes all Update Functions from the list
		/// </summary>
		public void ClearUpdate()
		{ update_functions.Clear(); }
		#endregion

		#region IDrawable Members
		public void Update(GameTime gametime)
		{
			foreach (Update update in update_functions)
				update(gametime);
		}

		public void Draw(GameTime gametime, SpriteBatch spritebatch, GraphicsDevice device)
		{
			foreach (Draw draw in draw_functions)
				draw(gametime, spritebatch, device);
		}

		public void Init(GameTime gametime, ContentManager manager)
		{
			draw_functions = new List<Draw>();
			update_functions = new List<Update>();
		}

		public void ScreensizeChanged()
		{
		}
		#endregion
	}
}
